package com.ymatou.iapi.push.testcase;

import com.ymatou.iapi.push.parameter.Enum.*;
import com.ymatou.iapi.push.parameter.pushBean;
import com.ymatou.iapi.push.service.decomposeCall;
import com.ymatou.iapi.push.service.pushCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.database.sqlwapper.ImDefaultWapper;
import org.junit.*;
import org.junit.experimental.categories.Category;

/**
*个推消息推送
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_push{
	private static com.ymatou.iapi.push.parameter.pushBean pushBean;
	private static com.ymatou.iapi.push.service.pushCall pushCall;
	private static ImDefaultWapper im = new ImDefaultWapper();
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("个推消息推送");
	}

	@Before
	public void caseUp() {
		pushBean=new pushBean();
		pushCall=new pushCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(pushCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	/**
	 * 本次case验证点：手机在通知栏会收到通知
	 */
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_push_001() {
		Logger.start(true,"个推消息推送，ios,toSingle");
		try {
			//appid

			pushBean.setA(AppIdType.ShenqiBuyer);
			//marktingFlag 是否是营销类消息
			pushBean.setMk(false);
			//phoneType 发送到指定手机类型
			pushBean.setSp(PhoneType.iOS);
			//badgeNum  iOS显示的图标数字
			pushBean.setBn(0);
			//messageTitle 消息标题
			pushBean.setMt("Hello,world");
			//messageBody 消息文本
			pushBean.setMb("Hello123");
			//pushToAllBindClientType 推送给所有跟此UserId绑定的客户端方式
			pushBean.setPa(PushToAllBindClientType.Newest);
			//payLoad 消息透传
			pushBean.setPl("{\"PushType\":\"123\"}");
			//isSendMessageTitle  发是否发送消息标题
			pushBean.setSmt(true);
			//offlineExpireSecondTime 当无法及时推送给用户时，最多存储时间(秒)
			pushBean.setEs(0);
			//netWorkType 在何种网络状态下发送(默认All)
			pushBean.setNt(PushNetWorkType.All);
			//key
			pushBean.setK("notify-85464298-e0dd-42e7-858f-4cd3ae5c8449");
			//userSystemType
			pushBean.setUst(UserSystemType.YmatouUser);
			//sendType 发送类型
			pushBean.setS(SendType.ToSingle);
			pushBean.setSu(20238699);
			pushBean.setT(GetuiProvinceType.All);
			pushBean.setDi("0B1CAAC5-EFAE-4C75-8641-35D689A4AD52");
			pushCall.setData(pushBean);
			pushCall.callService();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_push_004() {
		Logger.start(true,"个推消息推送，ios,toSingle,六个月之前");
		try {
			//appid
			pushBean.setA(AppIdType.ShenqiBuyer);
			//marktingFlag 是否是营销类消息
			pushBean.setMk(false);
			//phoneType 发送到指定手机类型
			pushBean.setSp(PhoneType.iOS);
			//badgeNum  iOS显示的图标数字
			pushBean.setBn(0);
			//messageTitle 消息标题
			pushBean.setMt("Hello,world");
			//messageBody 消息文本
			pushBean.setMb("Hello123");
			//pushToAllBindClientType 推送给所有跟此UserId绑定的客户端方式
			pushBean.setPa(PushToAllBindClientType.All);
			//payLoad 消息透传
			pushBean.setPl("{\"PushType\":\"123\"}");
			//isSendMessageTitle  发是否发送消息标题
			pushBean.setSmt(true);
			//offlineExpireSecondTime 当无法及时推送给用户时，最多存储时间(秒)
			pushBean.setEs(0);
			//netWorkType 在何种网络状态下发送(默认All)
			pushBean.setNt(PushNetWorkType.All);
			//key
			pushBean.setK("notify-85464298-e0dd-42e7-858f-4cd3ae5c8449");
			//userSystemType
			pushBean.setUst(UserSystemType.YmatouUser);
			//sendType 发送类型
			pushBean.setS(SendType.ToSingle);
			pushBean.setSu(20238699);
			pushBean.setT(GetuiProvinceType.All);
			pushBean.setDi("5DC3AEAC-BD42-47ED-8C4E-7B1097EF0CF7");
			pushCall.setData(pushBean);
			pushCall.callService();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_push_002() {
		Logger.start(true,	"个推消息推送，ios,toApp");
		try {
			//appid
			pushBean.setA(AppIdType.ShenqiBuyer);
			//marktingFlag 是否是营销类消息
			pushBean.setMk(false);
			//phoneType 发送到指定手机类型
			pushBean.setSp(PhoneType.iOS);
			//badgeNum  iOS显示的图标数字
			pushBean.setBn(0);
			//messageTitle 消息标题
			String message = "Hello,world";
			pushBean.setMt(message);
			//messageBody 消息文本
			String messagebody = "Hello123";
			pushBean.setMb(messagebody);
			//pushToAllBindClientType 推送给所有跟此UserId绑定的客户端方式
			pushBean.setPa(PushToAllBindClientType.All);
			//payLoad 消息透传
			pushBean.setPl("{\"PushType\":\"123\"}");
			//isSendMessageTitle  发是否发送消息标题
			pushBean.setSmt(true);
			//offlineExpireSecondTime 当无法及时推送给用户时，最多存储时间(秒)
			pushBean.setEs(0);
			//netWorkType 在何种网络状态下发送(默认All)
			pushBean.setNt(PushNetWorkType.All);
			//key
			pushBean.setK("notify-85464298-e0dd-42e7-858f-4cd3ae5c8449");
			//userSystemType
			pushBean.setUst(UserSystemType.YmatouUser);
			//sendType 发送类型
			pushBean.setS(SendType.ToSingle);
			pushBean.setSu(20226434);
			pushBean.setT(GetuiProvinceType.All);
			pushBean.setDi("5DC3AEAC-BD42-47ED-8C4E-7B1097EF0CF7");
			pushCall.setData(pushBean);
			pushCall.callService();

			decomposeCall decomposeCall = new decomposeCall();
			decomposeCall.callService();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_push_003() {
		Logger.start(true,	"个推消息推送，ios,toDeviceId");
		try {
			//appid
			pushBean.setA(AppIdType.ShenqiBuyer);
			//marktingFlag 是否是营销类消息
			pushBean.setMk(false);
			//phoneType 发送到指定手机类型
			pushBean.setSp(PhoneType.iOS);
			//badgeNum  iOS显示的图标数字
			pushBean.setBn(0);
			//messageTitle 消息标题
			String message = "Hello,world";
			pushBean.setMt(message);
			//messageBody 消息文本
			String messagebody = "Hello123";
			pushBean.setMb(messagebody);
			//pushToAllBindClientType 推送给所有跟此UserId绑定的客户端方式
			pushBean.setPa(PushToAllBindClientType.All);
			//payLoad 消息透传
			pushBean.setPl("{\"PushType\":\"123\"}");
			//isSendMessageTitle  发是否发送消息标题
			pushBean.setSmt(true);
			//offlineExpireSecondTime 当无法及时推送给用户时，最多存储时间(秒)
			pushBean.setEs(0);
			//netWorkType 在何种网络状态下发送(默认All)
			pushBean.setNt(PushNetWorkType.All);
			//key
			pushBean.setK("notify-85464298-e0dd-42e7-858f-4cd3ae5c8449");
			//userSystemType
			pushBean.setUst(UserSystemType.YmatouUser);
			//sendType 发送类型
			pushBean.setS(SendType.ToDevice);
			pushBean.setT(GetuiProvinceType.All);
			pushBean.setDi("5DC3AEAC-BD42-47ED-8C4E-7B1097EF0CF7");
			pushCall.setData(pushBean);
			pushCall.callService();

			decomposeCall decomposeCall = new decomposeCall();
			decomposeCall.callService();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}


}